{$CLEO .cs}
const
key_check = 13@
end
0000:
05E5: 0@ = game_version
gosub @restore

while true
wait 0
05E0: 12@ = read_memory 0xA10B4C size 1 virtual_protect 1 //controls    
if and
80E0:  not player $PLAYER_CHAR driving 
12@ <> 1
then 
05DF: write_memory 0x00A10B4C size 1 value 1 virtual_protect 1
end  
16@ = 0 
gosub @key_check  
if and
key_check == true
00E0:   player $PLAYER_CHAR driving  
84C9: not player $PLAYER_CHAR driving_flying_vehicle
then 
05E0: 1@ = read_memory 0x007E4764 size 4 virtual_protect 0 //current view
  if
  1@ == 1.0
  then
gosub @toggle
             while 00E0:   player $PLAYER_CHAR driving
             wait 0
gosub @rc_check
                if or
                00E1:   key_pressed 0 2
                00E1:   key_pressed 0 3
                00E1:   key_pressed 0 5
                00E1:   key_pressed 0 7
                00E1:   key_pressed 0 13
                //00E1:   key_pressed 0 17
                then     
                    break
                end 
             end
             gosub @restore                             
   end
   
  if
  1@ == 2.0
  then
gosub @toggle_20
             while 00E0:   player $PLAYER_CHAR driving
             wait 0
gosub @rc_check
                if or
                00E1:   key_pressed 0 2
                00E1:   key_pressed 0 3
                00E1:   key_pressed 0 5
                00E1:   key_pressed 0 7
                00E1:   key_pressed 0 13
                //00E1:   key_pressed 0 17
                then     
                    break
                end 
if
00E0:   player $PLAYER_CHAR driving
then                
05E0: 14@ = read_memory 0x94D790 size 4 virtual_protect 1 //X
05E0: 15@ = read_memory 0x94D794 size 4 virtual_protect 1 //Y
03C1: 13@ = player $player_char car_no_save
02E3: 13@ = car 13@ speed

  if and
  //13@ <> 0
  14@ == 0
  15@ == 0
  then
      if
      16@ > 2000
      then
      05DF: write_memory 0x00A10B4C size 1 value 0 virtual_protect 1
      16@ = 0
      end
  else
  05DF: write_memory 0x00A10B4C size 1 value 1 virtual_protect 1
  16@ = 0    
  end
end  
                
             end
             gosub @restore_20                             
   end         
end

if and
04C9: player $PLAYER_CHAR driving_flying_vehicle
00E1:   key_pressed 0 18
then
gosub @toggle 
while 00E1:   key_pressed 0 18
wait 0
if
84C9: not player $PLAYER_CHAR driving_flying_vehicle
then
break
end
end
gosub @restore
end

end

:rc_check
if
0@ == 0
then
5@ = 0x0094AD2C
else
5@ = 0x009412F4
end
05E0: 4@ = read_memory 5@ size 4 virtual_protect 0           
if
4@ <> 0
then
gosub @restore
while 4@ <> 0
05E0: 4@ = read_memory 5@ size 4 virtual_protect 0
wait 0
end
gosub @toggle 
end
return

:key_check
if and
80E1: not  key_pressed 0 2
80E1: not  key_pressed 0 3
80E1: not  key_pressed 0 5
80E1: not  key_pressed 0 7
80E1: not  key_pressed 0 17
80E1: not  key_pressed 0 13
then
key_check = true
else
key_check = false
end
return

:toggle
03C1: 6@ = player $player_char car_no_save  
05E7: 7@ = car 6@ struct
7@ += 0x1FA
05E0: 8@ = read_memory 7@ size 1 virtual_protect 1 //car flag

0373: set_camera_directly_behind_player 
if
0@ == 0
then
//toggle movement
05DF: write_memory 0x0046C63A size 1 value 0x74 virtual_protect 1  //0x75


//distances

if or
8@ == 32
8@ == 40
then
05DF: write_memory 0x68ACAC size 4 value 1.5 virtual_protect 1
05DF: write_memory 0x68AC9C size 4 value 6.0 virtual_protect 1
else
05DF: write_memory 0x68ACAC size 4 value 3.0 virtual_protect 1
05DF: write_memory 0x68AC9C size 4 value 9.0 virtual_protect 1
end



//patching lineOfsight
05DF: write_memory 0x0047C4B0 size 1 value 0x00 virtual_protect 1  //Vehicle

//patching camera motion
05DF: write_memory 0x0046B389 size 1 value 0x00 virtual_protect 1
05DF: write_memory 0x0046B58F size 1 value 0x00 virtual_protect 1

//hiding crosshair 
05DF: write_memory 0x55760A size 4 value 0x00688640 virtual_protect 1
else
:toggle11
//toggle movement
05DF: write_memory 0x0046C63A size 1 value 0x74 virtual_protect 1  //0x75

//distances
if or
8@ == 32
8@ == 40
then
05DF: write_memory 0x68ACAC size 4 value 1.5 virtual_protect 1
05DF: write_memory 0x68AC9C size 4 value 6.0 virtual_protect 1
else
05DF: write_memory 0x68ACAC size 4 value 3.0 virtual_protect 1
05DF: write_memory 0x68AC9C size 4 value 9.0 virtual_protect 1
end

//patching lineOfsight
05DF: write_memory 0x0047C4B0 size 1 value 0x00 virtual_protect 1  //Vehicle

//patching camera motion
05DF: write_memory 0x0046B389 size 1 value 0x00 virtual_protect 1
05DF: write_memory 0x0046B58F size 1 value 0x00 virtual_protect 1

//hiding crosshair 
05DF: write_memory 0x55762A size 4 value 0x00688640 virtual_protect 1
end
return

:restore
if
0@ == 0
then
//toggle movement *restore
05DF: write_memory 0x0046C63A size 1 value 0x75 virtual_protect 1  //0x75

//distances *restore
05DF: write_memory 0x68ACAC size 4 value 0.8 virtual_protect 1
05DF: write_memory 0x68AC9C size 4 value 2.0 virtual_protect 1

//patching lineOfsight *restore
05DF: write_memory 0x0047C4B0 size 1 value 0x01 virtual_protect 1  //Vehicle

//patching camera motion *restore
//05DF: write_memory 0x0046B389 size 1 value 0x01 virtual_protect 1
//05DF: write_memory 0x0046B58F size 1 value 0x01 virtual_protect 1

//hiding crosshair *restore
05DF: write_memory 0x55760A size 4 value 0x00A0D924 virtual_protect 1
else
:restore11
//toggle movement *restore
05DF: write_memory 0x0046C63A size 1 value 0x75 virtual_protect 1  //0x75

//distances *restore
05DF: write_memory 0x68ACAC size 4 value 0.8 virtual_protect 1
05DF: write_memory 0x68AC9C size 4 value 2.0 virtual_protect 1

//patching lineOfsight *restore
05DF: write_memory 0x0047C4B0 size 1 value 0x01 virtual_protect 1  //Vehicle

//patching camera motion *restore
//05DF: write_memory 0x0046B389 size 1 value 0x01 virtual_protect 1
//05DF: write_memory 0x0046B58F size 1 value 0x01 virtual_protect 1

//hiding crosshair *restore
05DF: write_memory 0x55762A size 4 value 0x00A0D92C virtual_protect 1
end
return




:toggle_20
03C1: 6@ = player $player_char car_no_save  
05E7: 7@ = car 6@ struct
7@ += 0x1FA
05E0: 8@ = read_memory 7@ size 1 virtual_protect 1 //car flag
 
if
0@ == 0
then
//toggle_20 movement
05DF: write_memory 0x0046C63A size 1 value 0x74 virtual_protect 1  //0x75
05DF: write_memory 0x007E47EC size 4 value 3.0 virtual_protect 1

//distances
if or
8@ == 32
8@ == 40
then
05DF: write_memory 0x68ACAC size 4 value 0.8 virtual_protect 1
05DF: write_memory 0x68AC9C size 4 value 6.2 virtual_protect 1
else
05DF: write_memory 0x68ACAC size 4 value 0.8 virtual_protect 1
05DF: write_memory 0x68AC9C size 4 value 9.2 virtual_protect 1
end



//patching lineOfsight
05DF: write_memory 0x0047C4B0 size 1 value 0x00 virtual_protect 1  //Vehicle

//patching camera motion
05DF: write_memory 0x0046B389 size 1 value 0x01 virtual_protect 1
05DF: write_memory 0x0046B58F size 1 value 0x01 virtual_protect 1

//hiding crosshair 
05DF: write_memory 0x55760A size 4 value 0x00688640 virtual_protect 1
else
:toggle_2011
//toggle_20 movement
05DF: write_memory 0x0046C63A size 1 value 0x74 virtual_protect 1  //0x75
05DF: write_memory 0x007E47EC size 4 value 3.0 virtual_protect 1   //not 1.1

//distances
if or
8@ == 32
8@ == 40
then
05DF: write_memory 0x68ACAC size 4 value 0.8 virtual_protect 1
05DF: write_memory 0x68AC9C size 4 value 6.2 virtual_protect 1
else
05DF: write_memory 0x68ACAC size 4 value 0.8 virtual_protect 1
05DF: write_memory 0x68AC9C size 4 value 9.2 virtual_protect 1
end

//patching lineOfsight
05DF: write_memory 0x0047C4B0 size 1 value 0x00 virtual_protect 1  //Vehicle

//patching camera motion
05DF: write_memory 0x0046B389 size 1 value 0x01 virtual_protect 1
05DF: write_memory 0x0046B58F size 1 value 0x01 virtual_protect 1

//hiding crosshair 
05DF: write_memory 0x55762A size 4 value 0x00688640 virtual_protect 1
end
return

:restore_20
if
0@ == 0
then
//toggle_20 movement *restore_20
05DF: write_memory 0x0046C63A size 1 value 0x75 virtual_protect 1  //0x75
                      
//distances *restore_20
05DF: write_memory 0x68ACAC size 4 value 0.8 virtual_protect 1
05DF: write_memory 0x68AC9C size 4 value 2.0 virtual_protect 1

//patching lineOfsight *restore_20
05DF: write_memory 0x0047C4B0 size 1 value 0x01 virtual_protect 1  //Vehicle

//patching camera motion *restore_20
//05DF: write_memory 0x0046B389 size 1 value 0x01 virtual_protect 1
//05DF: write_memory 0x0046B58F size 1 value 0x01 virtual_protect 1

//hiding crosshair *restore_20
05DF: write_memory 0x55760A size 4 value 0x00A0D924 virtual_protect 1
else
:restore_2011
//toggle_20 movement *restore_20
05DF: write_memory 0x0046C63A size 1 value 0x75 virtual_protect 1  //0x75

//distances *restore_20
05DF: write_memory 0x68ACAC size 4 value 0.8 virtual_protect 1
05DF: write_memory 0x68AC9C size 4 value 2.0 virtual_protect 1

//patching lineOfsight *restore_20
05DF: write_memory 0x0047C4B0 size 1 value 0x01 virtual_protect 1  //Vehicle

//patching camera motion *restore_20
//05DF: write_memory 0x0046B389 size 1 value 0x01 virtual_protect 1
//05DF: write_memory 0x0046B58F size 1 value 0x01 virtual_protect 1

//hiding crosshair *restore_20
05DF: write_memory 0x55762A size 4 value 0x00A0D92C virtual_protect 1
end
return